Inside Solaris logo
The Cobb Group This article is reprinted from the August 1996 issue of  Inside Solaris, a monthly publication of The Cobb Group.

Click for a FREE issue!


CUSTOMIZING YOUR ENVIRONMENT

Turning the File Manager into your command center

By Al Alexander

Many System administrators make a basic mistake about the users of their systems. They believe that most users enjoy working with the arcane intricacies of Solaris as much as they themselves do. It often comes as a shock when they discover that some users are more interested in completing their work than in working on the computer. These users rightly believe that their other work is more important than learning the syntax and command-line options of various Solaris commands. If you're in this situation, you can become an overnight hero when you learn this lesson. Instead of forcing your users to learn the command-line arcana of Solaris, you can find an easier way to bring the power of UNIX to them. One way you can do this is by transforming the seemingly innocent File Manager into a powerful, flexible command center.

Once you make this change, your users will have the ability to run a wide variety of UNIX commands from the File Manager without worrying about any obscure calling conventions. They can, for example, run their CAD and finite-element analysis (FEA) applications, run personal tape backups, manipulate custom batch queues, etc.--all from the confines of the File Manager.

This relatively low-technology solution brings home an important lesson in system administration: No matter how cool and interesting you find the new technologies, the users you support often don't care. It's not vital that you solve every problem with a flashy application. To most users, a simple, reliable way to do their jobs is what's important. In other words, they're looking for a way to make things work better so they'll be more productive.

In this article, we'll show you how you can extend the File Manager by adding new commands. This allows your system's users to do all their work from within the File Manager. Your endeavors may endear you to your users enough so that you receive that coveted "Most Valuable Employee of the Month" award you've been wanting.

Why use the File Manager?

The beauty of the File Manager approach is that for most end users, using a computer system is a file-oriented endeavor. All day long, users open, close, create, copy, delete, modify, and print files (or documents, if you prefer). If only you could make the File Manager perform other tasks, you'd have the perfect file-oriented tool for your users. Wouldn't it be great if you could simply select a set of files, select Fax, and have the File Manager ask you for the fax number to send the files to?

Obviously, we wouldn't tantalize you without telling you how to accomplish the task, so let's get down to business. First, you need to know that this trick works with the default File Manager used by OpenWindows, but not with the CDE version of File Manager.

Please note that if your users run CDE, then you can customize their environment in other ways to do similar tasks. However, we won't cover those techniques in this article. You can still use this technique, if you want, by running the OpenWindows version of File Manager under CDE. To do so, you should execute the program /usr/openwin/bin/filemgr.

Locating the custom commands menu

Solaris' File Manager for OpenWindows lets you create your own commands with the support of the Custom Commands option. Once you've defined them, custom commands are available to users through the File menu. You can see this in operation by starting the File Manager, clicking the File menu button, and then selecting the Custom Commands option. The resulting list shows you which custom commands you currently have configured for your system. The default application available from the custom commands menu is a UNIX Shell. In Figure A, we've created a sample menu to show you some of the things you can do with the Custom Commands option. As you see, you can add a large variety of commands. Please note that the UNIX Shell... entry is always on the Custom Command menu. If you invoke this option, it simply opens a Shell Tool window for you. Now let's see how to create our own custom commands.

Figure A

This sample menu shows some of the flexibility available when you use the Custom Commands option.

Adding a custom commands

It's very simple to add custom commands to the File Manager. We'll demonstrate the process by creating a command that will allow users to print one or more files to a printer named Accounting. To begin, start the File Manager. Then click the Edit button, and select Properties... from the Edit menu. When you do so, you'll see the FM: Properties dialog box. At the top of the dialog box, you'll see a dropdown menu labelled Categories. Click the down arrow and select Custom Commands. When you do so, the FM: Properties dialog box should look like the one shown in Figure B.

You'll use this screen to define all your new custom commands. Next, we'll describe all the items in this dialog box and simultaneously build our new custom print command.

Figure B

You can create new commands for File Manager with the FM: Properties dialog box.

Choosing a command

The first field on the Custom Command section of the FM: Properties dialog box is the UNIX Command field. You use this field to enter the command you want the custom command to execute. You may enter any command or script file in this field, along with any parameters you want to use. Let's begin with our new print command. Normally, when you want to print files to the Accounting printer, you execute the command

lp -dAccounting FileList

replacing FileList with the list of files you want to print. Similarly, if you want to print on a special form, you'd add the form name with the -f option. That's simple enough. But where do we get the list of files?

The $FILE token

The File Manager defines a special token, named $FILE, that you use to access the list of currently selected files. To do so, you simply add the $FILE token in the UNIX Command field in the position where you want the file list to appear. When the File Manager executes your custom command, it will replace the $FILE token with the entire list of files you've selected.

The $ARG token

Please note that the File Manager provides another token for your custom commands: the $ARG token. The File Manager allows you to prompt the user for special options for your custom command, as we'll discuss in the "Prompting the user" section. When you use the $ARG token, the File Manager replaces it with the user's response before it executes the custom command. For our new print command, we'll simply replace FileList with $FILE. Additionally, since the user may want some special print options, we'll add the $ARG token to allow this. Let's get started. Click on the UNIX Command field to select it. Now type the command you want to execute. Since we want our custom command to print a file to the Accounting printer, with the possibility of incorporating some options, we'll enter the command

lp $ARG -dAccounting $FILE

Now suppose the user highlighted two files named list.c and list.h and then invoked this custom command. Let's also suppose that the File Manager prompted the user for extra options, and the user replied -fLEGAL. In this case, the File Manager would replace the $FILE token with list.c list.h, then replace the $ARG token with -fLEGAL, and execute the command as follows:

lp -fLEGAL -dAccounting list.c list.h

Remember that the $FILE and $ARG tokens are case-sensitive. If you use any lowercase letters, the File Manager won't recognize them. For example, if you use $File instead of $FILE, then the custom command we set up will try to print a file named $File, no matter what files you've selected.

Since the File Manager is file-oriented, it expects custom commands to have an embedded $FILE token. If you haven't placed the $FILE token in your custom command, or if you've misspelled it, the File Manager will alert you with the message box shown in Figure C when you click the Add Item button.

Figure C

If you create a custom command without including the $FILE token, the File Manager alerts you with this dialog box.

If you don't intend for your custom command to use the $FILE token, just press the Apply button. If you want the File Manager to add $FILE to the end of your custom command, press the Add $FILE button. Otherwise, press the Cancel button and fix any problems with your custom command.

Naming your custom command

Now that we've told the File Manager what the custom command should do, we need to give it a label so the user can find it. The File Manager provides the Menu Label field to allow you to give your custom command a name. To do this, click on the Menu Label field and enter the command name; in this case, we'll enter Print to Accounting.

Prompting the user

While discussing the $ARG token, we alluded to the fact that you can have the File Manager prompt the user for more information when the user executes the custom command. You can use this feature by setting the Prompt Window field to Yes, then entering the prompt text you want the user to see in the Prompt field. When the user executes a custom command that has a prompt, the File Manager will create a new window to prompt the user with your custom prompt string. Then the File Manager will replace the $ARG token with the text you enter and the $FILE token (if present) with the list of selected files. Finally, the File Manager will execute the custom command.

In our example, we used the $ARG token in our custom command, so we should prompt the user for some additional information. To do so, set the Prompt Window field to Yes, then in the Prompt field, enter Printer Options to allow the user to specify any additional printer options for the job. When the user executes this custom command, the File Manager will present the Print to Accounting dialog box shown in Figure D.

Figure D

Your custom commands can tell the File Manager to prompt the user for further information on a command.

The output window

For many of your custom commands, you may choose to display the output of the UNIX command. You can do so by setting the Output Window field to Yes in the FM: Properties dialog box. Then, any output from the UNIX command will appear in a separate window that resembles a Shell Tool window. To close the output window, you select it (typically by clicking the mouse inside the window) and press the [Return] key. For our example command, we don't use the output window. So, click the No button next to the Output Window field to ensure that we don't accidentally open one.

However, when you're creating a custom command and it's giving you trouble, you may want to use the output window as a debugging aid. Many UNIX commands emit error messages when they fail. If you turn on the output window, you'll be able to see any error messages your custom command generates when it tries to run. So remember, if your custom command fails, turn on the output window and examine any output it may provide.

Adding your custom command to the menu

When you create your custom command, you need to add it to the Custom Commands Menu Items box. To do so, click the Add Item button along the right side of the dialog box. Adding the custom command to the Custom Commands Menu Items box doesn't tell the File Manager to begin using your new custom command. If you want to use these custom commands in the current File Manager session, you must press the Apply button, which tells the File Manager to forget any custom commands it previously stored and load new ones from the Custom Commands Menu Items box.

If you click the Save as Defaults button, you're telling the File Manager to save these custom commands in a special file. From now on, each time you start the File Manager, it will load your custom commands. If you don't click the Save as Defaults button, then the next time you start the File Manager, it will reuse the previous set of custom commands.

Since we want to use our new custom command immediately, go ahead and press the Apply button. We also want to save the command for future File Manager sessions, so press the Save as Defaults button, too. If you're the cautious type, you may want to press the Apply button and then test your custom command before actually saving it permanently.

At this point, your new print command should now be available from the Custom Commands submenu on the File menu. To check this, click the File button to pull down the File menu, then select the Custom Commands option. When you do so, you should see the menu label Print to Accounting, as shown in Figure E.

Figure E

As you can see, the Custom Commands submenu now has our Print to Accounting item available.

To use your new command, first select a file (or files), then select the Print to Accounting item. When you do so, the File Manager will prompt you with the dialog box shown in Figure D. Once you respond and press the Run button, File Manager will send the selected files with the specified options to the Accounting printer.

Changing your custom command list

Take another look at Figure B. See the Edit button to the right of the Custom Commands Menu Items list box? This pulldown menu allows you to delete and rearrange items in the Custom Commands Menu Items list box. This menu provides the options Cut, Copy, Paste, and Delete. The Paste submenu provides four variations: Before, After, Top, and Bottom, as you can see in Figure F. You can use these options just as you'd imagine. The Paste submenu lets you decide where to paste any custom command. BUG ALERT: Please note that you should use these edit options sparingly. It was our experience on all the systems on which we tried these options that the File Manager would easily crash if we overused these options.

Figure F

You can remove and change the order of the Custom Commands menu with the Edit pulldown menu.

Conclusion

Creating custom commands lets you turn your File Manager into a useful command center for your users. Once modified, the File Manager can become the end users' primary interface to the computer system and network, allowing them to launch UNIX commands, custom utilities, and full-blown applications from one location.

 

Alvin J. Alexander is an independent consultant specializing in UNIX and the Internet. He has worked on UNIX networks to support the Space Shuttle, international clients, and various Internet service providers. He has provided UNIX and Internet training to over 400 clients in the last three years.

 

[The Cobb Group Home Page]

Copyright (c) 1996 The Cobb Group, a division of Ziff-Davis Publishing Company. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of Ziff-Davis Publishing Company is prohibited. The Cobb Group and The Cobb Group logo are trademarks of Ziff-Davis Publishing Company.

Questions? Comments?